package com.ty.day6;

import java.io.*;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/29 14:27
 */
public class BufferReaderAndWriterDemo01 {
    public static void main(String[] args) throws IOException {
        //文件
        File file = new File("E:\\文件夹\\java\\1\\3.txt");
        File file1 = new File("E:\\文件夹\\java\\1\\4.txt");
        //文件输入输出流
        FileInputStream fis = new FileInputStream(file);
        FileOutputStream fos = new FileOutputStream(file1);
        //字节输入输出流
        InputStreamReader isr = new InputStreamReader(fis);
        OutputStreamWriter osw = new OutputStreamWriter(fos);
        //字符输入输出流
        BufferedReader br = new BufferedReader(isr);
        BufferedWriter bw = new BufferedWriter(osw);
        //边读边写
        String s ;
        while ((s= br.readLine()) != null) {
            System.out.println(s);
            bw.write(s);
            //换行
            bw.newLine();
        }
        //强制写入文件
        bw.flush();
        //关闭流
        br.close();
        bw.close();
        isr.close();
        osw.close();
        fis.close();
        fos.close();
    }
}
